package com.qf.springboot2.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.qf.springboot2.mapper.StudentMapper;
import com.qf.springboot2.pojo.Student;
import com.qf.springboot2.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public PageInfo<Student> findPage(int pageNum, int size) {

        PageHelper.startPage(pageNum,size);

        List<Student> students = studentMapper.findAll();

        return new PageInfo<>(students);
    }

    @Override
    @Transactional //开启事务
    public List<Student> findAll() {
        return studentMapper.findAll();
    }
}
